package com.tanhua.management.controller;

import cn.hutool.core.util.ObjectUtil;
import com.tanhua.management.service.LogManagerService;
import com.tanhua.management.vo.LogManagerVo;
import com.tanhua.management.vo.LogParamVo;
import com.tanhua.management.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("manage")
public class LogManagerController {

    @Autowired
    private LogManagerService logManagerService;

    @GetMapping("logs")
    public ResponseEntity<PageResult> logPage(LogParamVo logParamVo) {
        try {
            PageResult pageResult = logManagerService.logPage(logParamVo);
            if (ObjectUtil.isNotEmpty(pageResult)) {
                return ResponseEntity.ok(pageResult);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ResponseEntity.status(500).build();
    }
}
